import time
def readfile(filename):
    file = open(filename, 'r')
    data = file.readlines()
    file.close()
    return data

def sort(data):
    swapped = True
    while swapped:
        swapped = False
        for i in range(len(data) - 1):
            if int(data[i]) > int(data[i + 1]):
                data[i], data[i + 1] = data[i + 1], data[i]
                swapped = True

m1 = readfile("m1_sorted.txt")
t_start = time.time()
sort(m1)
t_finish = time.time()

print("m1_sorted.txt", round((t_finish-t_start)*1000), "milliseconds")

m2 = readfile("m2_reverse.txt")
t_start = time.time()
sort(m2)
t_finish = time.time()

print("m2_reverse.txt", round((t_finish-t_start)*1000), "milliseconds")

m3 = readfile("m3_shuffle.txt")
t_start = time.time()
sort(m3)
t_finish = time.time()

print("m3_shuffle.txt", round((t_finish-t_start)*1000), "milliseconds")
